/**
 * @author Andrey Anisimov <hercules@inbox.ru>
 */

import core.util.Listeners;

class AbstractEffect {

    /**
     * @constructor
     */
    this.AbstractEffect = function () {
        this.listeners = new Listeners([
            'onEffectStarted',
            'onEffectPaused',
            'onEffectStopped',
            'onEffectFinished',
            'onEffectResumed']);
    };

    /**
     * Starts/resumes the effect.
     */
    this.play = function () {
        // Abstract
    };

    /**
     * Stops the effect.
     */
    this.stop = function () {
        // Abstract
    };

    /**
     * Pauses the effect the effect.
     */
    this.pause = function () {
        // Abstract
    };

    /**
     * Checks whether the effect is playing.
     *
     * @return bool
     */
    this.isPlaying = function () {
        // Abstract
    };

    /**
     * Adds the effect listener.
     *
     * @param listener {Object} The listener to add.
     */
    this.addEffectListener = function (listener) {
        this.listeners.add(listener);
    };

    /**
     * Removes the effect listener.
     *
     * @param listener {Object} The listener to remove.
     */
    this.removeEffectListener = function (listener) {
        this.listeners.remove(listener);
    };

    /**
     * @protected
     * Fires when the effect has started.
     */
    this.fireStarted = function () {
        this.listeners.call('onEffectStarted', [ this ]);
    };

    /**
     * @protected
     * Fires when the effect has paused.
     */
    this.firePaused = function () {
        this.listeners.call('onEffectPaused', [ this ]);
    };

    /**
     * @protected
     * Fires when the effect has stopped.
     */
    this.fireStopped = function () {
        this.listeners.call('onEffectStopped', [ this ]);
    };

    /**
     * @protected
     * Fires when the effect has finished.
     */
    this.fireFinished = function () {
        this.listeners.call('onEffectFinished', [ this ]);
    };

    /**
     * @protected
     * Fires when the effect has resumed after a pause.
     */
    this.fireResumed = function () {
        this.listeners.call('onEffectResumed', [ this ]);
    };
}
